<?php
/*
 * @Author: CHINAKAIYUAN<sunkaiyuan@namenode.cn>
 * @Date: 2022-02-03 01:16:57
 * @LastEditTime: 2022-02-18 22:33:21
 * @LastEditors: CHINAKAIYUAN
 * @Description: 
 */

namespace App\Models;

use App\Traits\SoftDeletesTrait;

class Unit extends BaseModel
    {

    use SoftDeletesTrait;
    public $timestamps = true;
    public $table = "basedata_unit";
    protected $guarded = [];

    // 'firstunit', 'lastunit'
    public function firstunit()
        {
        return $this->belongsTo(Dic::class, "firstunit_id", "key")->where(function ($q)
            {
            $q->where("code", 'unit');
            });
        }
    public function lastunit()
        {
        return $this->belongsTo(Dic::class, "lastunit_id", "key")->where(function ($q)
            {
            $q->where("code", 'unit');
            });
        }
    }
